#ifndef ORQUERY_H
#define ORQUERY_H
#include"BinaryQuery.h"

class OrQuery : public BinaryQuery {
    friend Query operator| (const Query&,const Query&);
    OrQuery(const Query &left,const Query &right):BinaryQuery(left,right,"|"){}
    QueryResult eval(const TextQuery&) const override;
};
inline Query operator| (const Query &lhs, const Query&rhs){
    if(DEBUG) cout << "OrQuery(" << lhs.rep() << "," << rhs.rep() << ") constructed" << endl;
    return shared_ptr<Query_base>(new OrQuery(lhs,rhs));
};
QueryResult OrQuery::eval(const TextQuery& text) const{
    QueryResult left = lhs.eval(text), right = rhs.eval(text);
    auto ret_idxs = make_shared<std::set<int>>(left.begin(),left.end());
    ret_idxs->insert(right.begin(),right.end());
    return QueryResult(rep(),ret_idxs,left.get_file());
}
#endif 